import optionsx from './mjt'
import * as echarts from 'echarts'
let options = JSON.parse(JSON.stringify(optionsx))
// const { echarts } = window

export default (element, data) => {
  const old = echarts.getInstanceByDom(element)
  if (old) old.dispose()
  const chart = echarts.init(element, 'theme')
  // eslint-disable-next-line no-unused-vars
  if(data) {
    options.legend = data.legend
    options.xAxis = data.xAxis
    options.yAxis = data.yAxis
    options.series = data.series
  }
  chart.setOption(options)
  return chart
}
